﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Webdiyer.WebControls.Mvc;
using Models;
using IServices;

namespace MVCCompany.Controllers
{
    public class HomeController : Controller
    {
        public IBlogServices BlogServices
        {
            get
            {
                return _blogServices;
            }
        }
        private readonly IBlogServices _blogServices;
        public HomeController(IBlogServices blogServices)
        {
            this._blogServices = blogServices;
        }
        //
        // GET: /Home/

        public ActionResult Index(int? id, int pageSize = 20)
        {
            List<BlogInfo> blogList = BlogServices.GetAllBlogList().ToPagedList<BlogInfo>(id == null ? 1 : Convert.ToInt32(id), pageSize);
            ViewBag.BlogList = blogList;
            if (Request.IsAjaxRequest())
            {

            }
            return View(blogList);
        }
        //404Not Found
        public ActionResult NotFound()
        {
            return View();
        }
        //内部服务器错误 500
        public ActionResult InternalError()
        {
            return View();
        }
    }
}
